Skip to content

chore: properly handle files after git add - #201

Merged
tisonkun merged 2 commits into
mainfrom
improve
Jan 12, 2026
Merged

chore: properly handle files after git add #201
tisonkun merged 2 commits into
mainfrom
improve

Conversation

@tisonkun

Copy link
Copy Markdown
Member

cc @Lorilatschki

This should handle several edge cases as discussed with @Byron in #199 (comment)

I'm going to revise the integration tests and then cut a release, but it may take quite some time until I have spare time. When you need a release for using, please let me know so I can release it as is without other internal refactoring.

Signed-off-by: tison <wander4096@gmail.com>
Comment thread fmt/src/git.rs
Comment on lines -176 to +183
let status_iter = status_platform.into_index_worktree_iter(None)?;
let status_iter = status_platform.into_iter(None)?;
let now = gix::date::Time::now_local_or_utc();
for item in status_iter {
let item = item.context("failed to check git status item")?;
let rel_path = item.rela_path();
let rel_path = match &item {
Item::IndexWorktree(item) => item.rela_path(),
Item::TreeIndex(item) => item.location(),
};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in #199 (comment), the dirty state can be either:

  1. In the working tree, i.e., not yet git add-ed
  2. In the index, i.e., git add-ed but not yet committed.

into_index_worktree_iter returns only the diff between the index and the working tree, while into_iter returns all the diffs between the head-tree and the index, and the index and the working tree.

Signed-off-by: tison <wander4096@gmail.com>
@Lorilatschki

Copy link
Copy Markdown
Contributor

cc @Lorilatschki

This should handle several edge cases as discussed with @Byron in #199 (comment)

I'm going to revise the integration tests and then cut a release, but it may take quite some time until I have spare time. When you need a release for using, please let me know so I can release it as is without other internal refactoring.

We would need a release for using, so if it is not to much effort for you, we would love to get it 😄

@tisonkun
tisonkun merged commit f629f02 into main Jan 12, 2026
17 checks passed
@tisonkun
tisonkun deleted the improve branch January 12, 2026 10:32
@tisonkun

Copy link
Copy Markdown
Member Author

@Lorilatschki 6.4.0 Released with all these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants